package com.stlm2.dems.dao.impl;

import org.springframework.stereotype.Repository;

import com.stlm2.dems.entity.GoodsValueAddedServices;
import com.stlm2.dems.dao.GoodsValueAddedServicesDao;
import com.stlm2.core.base.impl.BaseDaoImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("goodsValueAddedServicesDao")
public class GoodsValueAddedServicesDaoImpl extends BaseDaoImpl<GoodsValueAddedServices> implements GoodsValueAddedServicesDao {
    @Override
    public List<GoodsValueAddedServices> getByGoodsId(int goodsId) {
        return selectList("getByGoodsId",goodsId);
    }

    @Override
    public GoodsValueAddedServices getByGoodsIdAndServiceId(int goodId, int serviceId) {
        Map<String,Object> map  = new HashMap<String, Object>();
         map.put("goodId",goodId);
         map.put("serviceId",serviceId);
        return selectOne("getByGoodIdServiceId",map);


    }

    @Override
    public boolean goodServiceMatch(int goodsId, int valueAddedServicesId) {

        GoodsValueAddedServices goodsValueAddedServices = new GoodsValueAddedServices();
        goodsValueAddedServices.setGoodsId(goodsId);
        goodsValueAddedServices.setValueAddedServicesId(valueAddedServicesId);
        List<GoodsValueAddedServices> list  =   queryList(-1,-1,goodsValueAddedServices);
        if(list.size()>0){
             return true;

        }else{
            return false;
        }

    }
}